import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SliverPage extends StatelessWidget {
  final String _image = 'assets/images/top_bg.png';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            title: Text(
              'flutter demo',
              style: TextStyle(fontSize: 18, color: Colors.black),
              textAlign: TextAlign.center,
            ),
            expandedHeight: 300,
            //阴影
            forceElevated: true,
            // //下滑是否显示标题栏
            floating: false,
            //惯性展开、收缩，forceElevated: true时才能使用
            // snap: true,
            //折叠状态下，标题栏是否展示
            pinned: true,
            //设置背景
            flexibleSpace: FlexibleSpaceBar(
              //动画
              collapseMode: CollapseMode.parallax,
              background: Image.asset(_image, fit: BoxFit.cover),
            ),
          ),
          SliverFixedExtentList(
              delegate: SliverChildBuilderDelegate(
                (_, index) => Center(child: Text('data')),
                childCount: 3,
              ),
              itemExtent: 50.0),
        ],
      ),
    );
  }
}
